/*
Copyright [2023] [fuwen_soft]
*/
package vip.xiaonuo.modular.xyethnic.controller;

import vip.xiaonuo.core.annotion.BusinessLog;
import vip.xiaonuo.core.annotion.Permission;
import vip.xiaonuo.core.enums.LogAnnotionOpTypeEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import vip.xiaonuo.core.pojo.page.PageResult;
import vip.xiaonuo.modular.xyethnic.param.XyEthnicParam;
import vip.xiaonuo.modular.xyethnic.service.XyEthnicService;
import vip.xiaonuo.modular.xyethnic.entity.XyEthnic;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.validation.annotation.Validated;
import vip.xiaonuo.core.annotion.version.AdminVersionSwagger;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import javax.annotation.Resource;
import java.util.List;
import vip.xiaonuo.sys.core.msg.Result;
import static vip.xiaonuo.sys.core.msg.ResultUtils.success;
/**
 * 族员控制器
 *
 * @author yanwei
 * @date 2023-05-05 15:44:28
 */
@RestController
@Api(tags = "后台管理 族员 相关APIS")
@AdminVersionSwagger
public class XyEthnicController {

    @Resource
    private XyEthnicService xyEthnicService;

    /**
     * 查询族员
     *
     * @author yanwei
     * @date 2023-05-05 15:44:28
     */
    @Permission
    @GetMapping("/xyEthnic/page")
    @BusinessLog(title = "族员_查询", opType = LogAnnotionOpTypeEnum.QUERY)
    @ApiOperation("族员_查询")
    public Result<PageResult<XyEthnic>> page(XyEthnicParam xyEthnicParam) {
        PageResult<XyEthnic> page = xyEthnicService.page(xyEthnicParam);
        return success(page);
    }

    /**
     * 添加族员
     *
     * @author yanwei
     * @date 2023-05-05 15:44:28
     */
    @Permission
    @PostMapping("/xyEthnic/add")
    @BusinessLog(title = "族员_增加", opType = LogAnnotionOpTypeEnum.ADD)
    @ApiOperation("族员_增加")
    public Result add(@RequestBody @Validated(XyEthnicParam.add.class) XyEthnicParam xyEthnicParam) {
            xyEthnicService.add(xyEthnicParam);
        return success();
    }

    /**
     * 删除族员，可批量删除
     *
     * @author yanwei
     * @date 2023-05-05 15:44:28
     */
    @Permission
    @PostMapping("/xyEthnic/delete")
    @BusinessLog(title = "族员_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    @ApiOperation("族员_删除")
    public Result delete(@RequestBody @Validated(XyEthnicParam.delete.class) List<XyEthnicParam> xyEthnicParamList) {
            xyEthnicService.delete(xyEthnicParamList);
        return success();
    }

    /**
     * 编辑族员
     *
     * @author yanwei
     * @date 2023-05-05 15:44:28
     */
    @Permission
    @PostMapping("/xyEthnic/edit")
    @BusinessLog(title = "族员_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    @ApiOperation("族员_编辑")
    public Result edit(@RequestBody @Validated(XyEthnicParam.edit.class) XyEthnicParam xyEthnicParam) {
            xyEthnicService.edit(xyEthnicParam);
        return success();
    }

    /**
     * 查看族员
     *
     * @author yanwei
     * @date 2023-05-05 15:44:28
     */
    @Permission
    @GetMapping("/xyEthnic/detail")
    @BusinessLog(title = "族员_查看", opType = LogAnnotionOpTypeEnum.DETAIL)
    @ApiOperation("族员_查看")
    public Result<XyEthnic> detail(@Validated(XyEthnicParam.detail.class) XyEthnicParam xyEthnicParam) {
        XyEthnic detail =   xyEthnicService.detail(xyEthnicParam);
        return success(detail);
    }

    /**
     * 族员列表
     *
     * @author yanwei
     * @date 2023-05-05 15:44:28
     */
    @Permission
    @GetMapping("/xyEthnic/list")
    @BusinessLog(title = "族员_列表", opType = LogAnnotionOpTypeEnum.QUERY)
    @ApiOperation("族员_列表")
    public Result<List<XyEthnic>> list(XyEthnicParam xyEthnicParam) {
        List<XyEthnic> list  =   xyEthnicService.list(xyEthnicParam);
        return success(list);
    }

    /**
     * 导出系统用户
     *
     * @author yanwei
     * @date 2023-05-05 15:44:28
     */
    @Permission
    @GetMapping("/xyEthnic/export")
    @BusinessLog(title = "族员_导出", opType = LogAnnotionOpTypeEnum.EXPORT)
    @ApiOperation("族员_导出")
    public void export(XyEthnicParam xyEthnicParam) {
        xyEthnicService.export(xyEthnicParam);
    }

}
